home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Communications / General / LineShare Folder / Put Onto Productions Disks / LineShare Scripts / Generic Fax2&ARA&TeleFinder < prev    next >
Text File  |  1993-12-11  |  6KB  |  300 lines

  1. ! Version 2.1
  2. !
  3. !$ Requires: Class 2 fax modem, hardware handshaking cable.
  4.  
  5. !$ Supports: fax, ARA, and TeleFinder Group Edition software in the server mode.
  6.  
  7. !$ Use:   Class 2 for Fax, ARA/LineShare for ARA.
  8.  
  9. !$ Read:  your modem manual to modify the "AT" strings.
  10.  
  11. !$ See:   the Generic Scripts Guide for details.
  12.  
  13. ^2 Speaker On:        = Enum("Never" = "0" ,  "When Connecting" = "1", "Always"="2") "1"
  14. ^3 Speaker Volume:    = Enum("Low"="1","Medium"="2","High"="3") "2"
  15. ^4 Answer On:         = Enum("1 Ring"="1","2 Rings"="2","3 Rings"="3","5 Rings"="5","7 Rings"="7") "2"
  16. ^5 Fax Identifier:    = Text "Stalker_GmbH"
  17. ^6 AT for Receive:      = Text ""
  18. ^7 AT for HW Handshake:    = Text ""
  19. ^8 AT for SW Handshake: = Text ""
  20. ^9 AT for Normal mode:  = Text ""
  21.  
  22. ! ------------------------------------------
  23. ! Resetting the modem:
  24. ! ------------------------------------------
  25. @Hangup
  26.   SetTries 2
  27.   Flush
  28.   HsReset 0,0,17,19,0,0
  29. !
  30. ! Try to catch the "OK" answer, use the Escape seq and DTR transitions
  31. ! to enter the command mode
  32. !
  33. @Label 1
  34.   matchclr
  35.   matchstr 1 2 "OK\r\n"
  36.   write "ATH0&F\r"
  37.   matchread 20
  38.   Write "+++"
  39.   DtrClear
  40.   pause 10
  41.   DtrSet
  42. !
  43.   DecTries
  44.   IfTries 0 1
  45. !
  46. ! OSErr -6019 "Modem error - the modem is not responding"
  47. !
  48.   exit -6019
  49. @Label 2
  50.   write "AT+FCLASS=0\r"
  51.   Jsr 100
  52.   write "AT+FAA=0\r"
  53.   Jsr 100
  54.   exit 0
  55. ! ------------------------------------------
  56. !    Receiving incoming calls
  57. ! ------------------------------------------
  58. @ANSWER
  59.   SetVar A ""
  60.   IfStr A 50 "^6^7^8"
  61. @Label 10
  62.   SerReset 19200,0,8,1
  63.   Jsr 80
  64. !
  65. ! Set the common options
  66.   Jsr 70
  67. !
  68. ! Set the communication options:
  69. ! • ^6 for receive mode (disable MNP), <DCE Speed>/ARQ message
  70. ! • ^7 HW flow control
  71. !!
  72.   Write "AT^7^6\r"
  73.   Jsr 100
  74. !
  75. ! Set Fax parameters: LID, DCC,BOR
  76. !
  77.   Write "AT+FCLASS=2\r"
  78.   Jsr 100
  79.   Write "AT+FLID=\"^5\"\r"
  80.   Jsr 100
  81.   Write "AT+FDCC=1,3,0,2,0,0,0,0\r"
  82.   Jsr 100
  83.   Write "AT+FBOR=1\r"
  84.   Jsr 100
  85. !
  86. ! Allow modem to receive fax messages
  87. !
  88.   Write "AT+FCR=1\r"
  89.   Jsr 100
  90. !
  91. ! Tell the modem to determine the type of the incoming call
  92. ! Fetch the tube after ^4 rings
  93. !
  94.   Write "ATS0=^4+FAA=1\r"
  95.   Jsr 100
  96.   Note "Waiting for Fax/ARA/TeleFinder calls…"
  97. !
  98. ! Everything is ready - let's sit and wait for a call
  99. ! We'll wait for 2 minutes, then reinitiate the modem
  100. !
  101. @Label 12
  102.   MatchClr
  103.   matchstr 1 13 "RING\r\n"
  104.   matchstr 2 21 "\r\nCONNECT ^$/ARQ"
  105.   matchstr 3 15 "\r\nCONNECT ^$\r\n"
  106.   matchstr 9 40 "\r\n+FCON"
  107.   matchstr 10 10 "\r\nNO "
  108.   matchstr 11 10 "\r\nBUSY"
  109.   Matchread 1200
  110.   Jump 10
  111. @Label 13
  112.   Note "Ring…"
  113.   Jump 12
  114. !
  115. ! Data connection has been established (we read "CONNECT XXX\r\n")
  116. ! Put the "CONNECT" back to the buffer and attach the "Data" subPort
  117. ! if it was an incoming call, put the "RING" before the "CONNECT"
  118. !
  119. @Label 15
  120.   SetVar A "^$"
  121.   Note "Non-V.42 Call at ^A bps. Waiting for an ARA frame."
  122.   MatchClr
  123.   MatchStr 1 20 "\r"
  124.   MatchStr 2 30 "\08\01\03\14\04\03\00\08\250\16\03"
  125.   MatchRead 40
  126.  
  127. @Label 20
  128.   Note "Non-ARA call"
  129.   Flush
  130.   Jump 24
  131. !
  132. ! V.42 call detected
  133. !
  134. @Label 21
  135.   SetVar A "^$"
  136.   Note "V.42 Call at ^A bps"
  137.   MatchClr
  138.   MatchStr 1 24 "\r\n"
  139.   MatchRead 5
  140. @Label 24
  141.   QueueInput "\r\27RING\r\27\r\27CONNECT ^A\r\27"
  142. @Label 25
  143.   Attach "TF" (DTR,Break,Escape,TimeLimit=0)
  144.  
  145. !
  146. ! The ARA (MNP 4) frame detected
  147. !
  148. @Label 30
  149.   Note "ARA call at ^A bps."
  150.   Flush
  151.   QueueInput "\r\nRING\r\n\r\nCARRIER ^A\r\n"
  152. @Label 32
  153.   Attach "ARA" (DTR,Escape,TimeLimit=0)
  154.  
  155. !
  156. ! Fax connection has been established (we read "+FCON")
  157. ! Put the +FCON back to the buffer,
  158. ! if it was an incoming call, put the "RING" before the "+FCON"
  159. ! Attach the "Fax" subPort
  160. !
  161. @Label 40
  162.   QueueInput "\r\n+FCON"
  163.   ifOriginate 41
  164.   QueueInput "\r\nRING\r\n"
  165. @Label 41
  166.   Attach "Fax" (DTR,Reset,Escape,IdleLimit=30)
  167.  
  168. ! ------------------------------------------
  169. ! Originating a call through the "ARA" subport
  170. ! ------------------------------------------
  171. @ORIGINATE "ARA"
  172.   SerReset 19200,0,8,1
  173.   Jsr 80
  174. !
  175. ! Set the common options
  176. !
  177.   Jsr 70
  178. !
  179. ! Set the Data mode:
  180. ! • ^9 Normal connection, DCE speed
  181. ! • ^7  Hardware handshake
  182. ! • S7:  time-out (90 sec) for long-distance call (if you use them)
  183. !
  184.   Write "AT^7^9\r"
  185.   Jsr 100
  186. !
  187. ! Prepare to receive all error result codes
  188. !
  189.   Jsr 90
  190.   MatchStr 1 45 "\r\nCONNECT "
  191.   MatchRead 900
  192.   Write "\r"
  193.   Exit -6019
  194.  
  195. @Label 45
  196.   QueueInput "\r\nCARRIER "
  197.   Jump 32
  198.  
  199. ! ------------------------------------------
  200. ! Originating a call through the "Fax" subPort
  201. ! ------------------------------------------
  202. @ORIGINATE "Fax" ("\r\nLineShare Line is Busy\r\nBUSY\r\n")
  203.   SerReset 19200,0,8,1
  204.   Jsr 80
  205. !
  206. ! Set the common options
  207. !
  208.   Jsr 70
  209. !
  210. ! Set the Fax mode
  211. !
  212.   Write "AT^8+FCLASS=2\r"
  213.   Jsr 100
  214. !
  215. ! Now emit all commands that the application has sent to that port,
  216. ! Prepare to receive all error result codes
  217. !
  218.   Jsr 60
  219.   Jsr 90
  220.   MatchStr 1 40 "\r\n+FCON"
  221.   MatchRead 700
  222.   Write "\r"
  223.   Exit -6019
  224.  
  225. !
  226. @Label 50
  227.   Note "Suspended"
  228.   Say "Press the Option button to enter the AT-strings for your modem!"
  229.   Pause 1200
  230.   Jump 50
  231.  
  232. !
  233. ! This section emits all modem commands sent from the client application
  234. ! For each set of commands the "OK" answer is awaited
  235. !
  236. @Label 60
  237.   EmitStart
  238. @Label 61
  239.   EmitCommand 62
  240.   Jsr 100
  241.   Jump 61
  242. @Label 62
  243.   return
  244. !
  245. ! This section initiates the modem before ANSWER and ORIGINATEs:
  246. ! dialtone detect + connect at the highest rate + speaker control +
  247. ! hang up on Dtr drop + DCD valid
  248. ! Verbal responses mode, no echo
  249. ! Disable extended codes
  250. !
  251. @Label 70
  252.   Write "ATX4M^2L^3&D2&C1V1E0\r"
  253.   Jsr 100
  254.   return 
  255. !
  256. ! This section syncronize the modem after the serial port speed switching
  257. !
  258. @Label 80
  259.   ChrDelay 1
  260.   Write "AT\r"
  261.   ChrDelay 0
  262.   Jsr 100
  263.   return
  264. !
  265. ! Prepare to receive error result codes
  266. !
  267. @Label 90
  268.   MatchClr
  269.   MatchStr 2 91 "NO DIALTONE\r\n"
  270.   MatchStr 3 92 "BUSY\r\n"
  271.   MatchStr 4 93 "NO CARRIER\r\n"
  272.   MatchStr 5 94 "NO ANSWER\r\n"
  273.   Write "ATD^1\r"
  274.   HsReset *
  275.   return
  276.  
  277. @Label 91
  278.   exit -6020
  279. @Label 92
  280.   exit -6022
  281. @Label 93
  282.   exit -6021
  283. @Label 94
  284.   exit -6023
  285. !
  286. ! Processing the AT command:
  287. ! OK -> proceed
  288. ! ERROR or TimeOut ->exit -6019
  289. ! It can be called AFTER the "Write" command, since LineShare buffers input
  290. !
  291. @Label 100
  292.   MatchClr
  293.   MatchStr 1 102 "\r\nOK\r\n"
  294.   MatchStr 2 101 "\r\nERROR\r\n"
  295.   MatchRead 20
  296. @Label 101
  297.   Exit -6019
  298. @Label 102
  299.   return
  300.